package com.itheima.travel.config;

import com.itheima.travel.interceptors.LoginInterceptor;
import org.redisson.spring.session.config.EnableRedissonHttpSession;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

//声明spring-mvc的配置类
@ComponentScan("com.itheima.travel.web")
@Configuration
@EnableRedissonHttpSession//EnableRedissonHttpSession开启session共享
public class PlatformSpringMvcConfig extends SpringMvcConfig{

    //登录拦截
    @Bean("loginInterceptor")
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }
    //拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录拦截器
        registry.addInterceptor(loginInterceptor()).
                addPathPatterns("/**").
                excludePathPatterns( "/**/userService/*","/**/sellerService/*","/**/categoryService/findAllCategory");
    }
}
